home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / utilit~1 / futilsrc.zoo / fileutil / configure < prev    next >
Encoding:
Text File  |  1991-08-26  |  9.2 KB  |  342 lines

  1. :
  2. # Guess values for system-dependant variables and create `Makefile'.
  3. # Copyright (C) 1991 Free Software Foundation, Inc.
  4.  
  5. # This program is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; either version 2, or (at your option)
  8. # any later version.
  9.  
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. # GNU General Public License for more details.
  14.  
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software
  17. # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  
  19. # Usage: configure [+srcdir=DIR] [+host=HOST] [+gas] [+nfp] [TARGET]
  20. # All args except +srcdir=DIR are ignored.
  21.  
  22. trap 'rm -f conftest conftest.c uttest; exit 1' 1 3 15
  23.  
  24. set +u # Make sure unset variables are ok.
  25.  
  26. # A filename unique to this package, relative to the directory that
  27. # configure is in, which we can look for to find out if srcdir is correct.
  28. unique_file=src/ls.c
  29.  
  30. for arg in $*; do
  31.   # Handle +srcdir with a space before the argument.
  32.   if [ x$next_srcdir = xyes ]; then srcdir=$arg; next_srcdir=
  33.   # Handle +host with a space before the argument.
  34.   elif [ x$next_host = xyes ]; then next_host=
  35.   else 
  36.     case $arg in
  37.      -srcdir=* | +srcdir=* | +srcdi=* | +srcd=* | +src=* | +sr=* | +s=*)
  38.     srcdir=`echo $arg | sed 's/[+-]s[a-z]*=//'` ;;
  39.      -srcdir | +srcdir | +srcdi | +srcd | +src | +sr | +s)
  40.     next_srcdir=yes ;;
  41.      -host=* | +host=* | +hos=* | +ho=* | +h=*) ;;
  42.      -host | +host | +hos | +ho | +h)
  43.     next_host=yes ;;
  44.      -gas | +gas | +ga | +g) ;;
  45.      -nfp | +nfp | +nf | +n) ;;
  46.      *) ;;
  47.     esac
  48.   fi
  49. done
  50.  
  51. vpsub='s@\$\([-./a-zA-Z0-9]*\)<@\1@g'
  52. # Find the source files, if location was not specified.
  53. if [ x$srcdir = x ]; then
  54.   srcdirdefaulted=yes; srcdir=.
  55.   if [ ! -r $unique_file ]; then srcdir=`pwd`/..; fi
  56. fi
  57. if [ $srcdir != . ]; then
  58.   VPATH='VPATH = $(srcdir)'
  59.   vpsub='s@\$\([-./a-zA-Z0-9]*\)<@\$<@g'
  60. fi
  61.  
  62. if [ ! -r $srcdir/$unique_file ]; then
  63.   if [ x$srcdirdefaulted = xyes ]; then
  64.     echo "$0: Can not find sources in \`.' or \`..'." 1>&2
  65.   else
  66.     echo "$0: Can not find sources in \`${srcdir}'." 1>&2
  67.   fi
  68.   exit 1
  69. fi
  70.  
  71. if test "$RANDOM" = "$RANDOM"; then
  72.   # Plain old Bourne shell.
  73.   echo checking for gcc
  74.   test -z "$CC" -a -n "`gcc 2>&1`" && CC="gcc -O"
  75.  
  76.   echo checking for ranlib
  77.   test -z "$RANLIB" -a -n "`ranlib conftest 2>&1`" && RANLIB=ranlib
  78.   rm -f conftest
  79. else
  80.   # ksh, bash or zsh.  ksh and zsh write "command not found" to stderr.
  81.   echo checking for gcc
  82.   test -z "$CC" && type gcc && CC="gcc -O"
  83.  
  84.   echo checking for ranlib
  85.   test -z "$RANLIB" && type ranlib && RANLIB=ranlib
  86. fi
  87.  
  88. CC=${CC-cc}
  89. RANLIB=${RANLIB-echo}
  90. INCLUDEDIR=${INCLUDEDIR-/usr/include}
  91.  
  92. rm -f conftest conftest.c
  93. compile="$CC $DEFS conftest.c -o conftest $LIBS >/dev/null 2>&1"
  94.  
  95. # Check for various header files.
  96.  
  97. echo checking signal handler return type
  98. grep 'int[     ]*(\*signal[     ]*(' $INCLUDEDIR/signal.h \
  99.   $INCLUDEDIR/sys/signal.h >/dev/null 2>&1 &&
  100.   DEFS="$DEFS -DSIGTYPE=int"
  101.  
  102. echo checking for sys/mkdev.h
  103. if test -f $INCLUDEDIR/sys/mkdev.h; then
  104.   DEFS="$DEFS -DMAJOR_IN_MKDEV"
  105. fi
  106.  
  107. echo checking for directory library header
  108. if test -f $INCLUDEDIR/dirent.h; then
  109.   DEFS="$DEFS -DDIRENT"
  110. elif test -f $INCLUDEDIR/sys/ndir.h; then
  111.   DEFS="$DEFS -DSYSNDIR"
  112. elif grep 'void.*closedir' $INCLUDEDIR/sys/dir.h >/dev/null 2>&1; then
  113.   DEFS="$DEFS -DVOID_CLOSEDIR"
  114. fi
  115.  
  116. echo checking for st_blocks in struct stat
  117. echo "#include <sys/types.h>
  118. #include <sys/stat.h>
  119. main() { struct stat s; exit(0); s.st_blocks; }" > conftest.c
  120. eval $compile
  121. if test -s conftest && ./conftest 2>/dev/null; then :
  122. else
  123.   DEFS="$DEFS -DST_BLOCKS_MISSING"
  124.   LIBOBJS="$LIBOBJS fileblocks.o"
  125. fi
  126. rm -f conftest conftest.c
  127.  
  128. echo checking how to get filesystem info
  129. if test -f $INCLUDEDIR/sys/statvfs.h -a -f $INCLUDEDIR/sys/fstyp.h; then
  130.   DEFS="$DEFS -DFS_STATVFS" PROGS="$PROGS df" LIBOBJS="$LIBOBJS fsinfo.o"
  131. elif test -f $INCLUDEDIR/sys/statfs.h -a -f $INCLUDEDIR/sys/fstyp.h; then
  132.   DEFS="$DEFS -DFS_USG_STATFS" PROGS="$PROGS df" LIBOBJS="$LIBOBJS fsinfo.o"
  133. elif test -f $INCLUDEDIR/mntent.h; then
  134.   DEFS="$DEFS -DFS_MNTENT" PROGS="$PROGS df" LIBOBJS="$LIBOBJS fsinfo.o"
  135. elif test -f $INCLUDEDIR/sys/mount.h -a -f $INCLUDEDIR/sys/fs_types.h; then
  136.   DEFS="$DEFS -DFS_GETMNT" PROGS="$PROGS df" LIBOBJS="$LIBOBJS fsinfo.o"
  137. elif grep MOUNT_UFS $INCLUDEDIR/sys/mount.h >/dev/null 2>&1; then
  138.   DEFS="$DEFS -DFS_STATFS" PROGS="$PROGS df" LIBOBJS="$LIBOBJS fsinfo.o"
  139. fi
  140.  
  141. echo checking for ANSI C header files
  142. echo "#include <stdlib.h>
  143. #include <string.h>
  144. main() { exit(0); strerror(0); }" > conftest.c
  145. eval $compile
  146. if test -s conftest && ./conftest 2>/dev/null; then
  147.   DEFS="$DEFS -DSTDC_HEADERS"
  148. fi
  149. rm -f conftest conftest.c
  150.  
  151. echo checking for POSIX.1 header files
  152. echo "#include <unistd.h>
  153. main() {
  154. #ifdef _POSIX_VERSION
  155. exit(0);
  156. #else
  157. exit(1);
  158. #endif
  159. }" > conftest.c
  160. eval $compile
  161. if test -s conftest && ./conftest 2>/dev/null; then
  162.   DEFS="$DEFS -DPOSIX"
  163. fi
  164. rm -f conftest conftest.c
  165.  
  166. echo checking for BSD string and memory functions
  167. echo "#include <strings.h>
  168. main() { exit(0); rindex(0, 0); bzero(0, 0); }" > conftest.c
  169. eval $compile
  170. if test -s conftest && ./conftest 2>/dev/null; then :
  171.   else DEFS="$DEFS -DUSG"
  172. fi
  173. rm -f conftest conftest.c
  174.  
  175. echo checking whether sys/types.h defines uid_t
  176. echo '#include <sys/types.h>
  177. main() { uid_t x; exit(0); }' > conftest.c
  178. eval $compile
  179. if test -s conftest && ./conftest 2>/dev/null; then :
  180. else
  181.   uid_t=`awk '/pw_uid;/ {print $1}' $INCLUDEDIR/pwd.h`
  182.   DEFS="$DEFS -Duid_t=${uid_t} -Dgid_t=${uid_t}"
  183. fi
  184. rm -f conftest conftest.c
  185.  
  186. # Check whether various functions exist.
  187.  
  188. # Functions we provide replacements for.
  189. for func in fnmatch mkdir mktime stpcpy strdup strstr rename
  190. do
  191.   echo checking for $func
  192.   echo "main() { exit(0); ${func}(); }" > conftest.c
  193.   eval $compile
  194.   if test -s conftest && ./conftest 2>/dev/null; then :
  195.   else LIBOBJS="$LIBOBJS ${func}.o"
  196.   fi
  197.   rm -f conftest conftest.c
  198. done
  199.  
  200. # Functions whose absence we work around.
  201. for func in fchmod ftime mkfifo vprintf
  202. do
  203.   echo checking for $func
  204.   echo "main() { exit(0); ${func}(); }" > conftest.c
  205.   eval $compile
  206.   if test -s conftest && ./conftest 2>/dev/null; then :
  207.   else DEFS="$DEFS -D`echo $func|tr '[a-z]' '[A-Z]'`_MISSING"
  208.   fi
  209.   rm -f conftest conftest.c
  210. done
  211.  
  212. case "$DEFS" in
  213. *VPRINTF_MISSING*)
  214.   func=_doprnt
  215.   echo checking for $func
  216.   echo "main() { exit(0); ${func}(); }" > conftest.c
  217.   eval $compile
  218.   if test -s conftest && ./conftest 2>/dev/null; then :
  219.   else DEFS="$DEFS -DDOPRNT_MISSING"
  220.   fi
  221.   rm -f conftest conftest.c
  222.   ;;
  223. esac
  224.  
  225. func=ftruncate
  226. echo checking for $func
  227. echo "main() { exit(0); ${func}(); }" > conftest.c
  228. eval $compile
  229. if test -s conftest && ./conftest 2>/dev/null; then :
  230. else
  231.   rm -f conftest conftest.c
  232.   echo "#include <sys/types.h>
  233. #include <fcntl.h>
  234. main() {
  235. #if defined(F_CHSIZE) || defined(F_FREESP)
  236. exit(0);
  237. #else
  238. exit(0); chsize();
  239. #endif
  240. }" > conftest.c
  241.   eval $compile
  242.   if test -s conftest && ./conftest 2>/dev/null; then
  243.     LIBOBJS="$LIBOBJS ${func}.o"
  244.   else DEFS="$DEFS -D`echo $func|tr '[a-z]' '[A-Z]'`_MISSING"
  245.   fi
  246. fi
  247. rm -f conftest conftest.c
  248.  
  249. # Check other misc. things.
  250.  
  251. echo checking integer size
  252. echo "main() { exit(!(sizeof(long) > sizeof(int))); }" > conftest.c
  253. eval $compile
  254. ./conftest && DEFS="$DEFS -DINT_16_BITS"
  255. rm -f conftest conftest.c
  256.  
  257. echo checking utime with null argument
  258. rm -f uttest; > uttest
  259. # Sequent interprets utime(file, 0) to mean use start of epoch.  Wrong.
  260. echo '#include <sys/types.h>
  261. #include <sys/stat.h>
  262. main() {
  263. struct stat s, t;
  264. exit(!(stat ("uttest", &s) == 0 && utime("uttest", (long *)0) == 0
  265. && stat("uttest", &t) == 0 && t.st_mtime - s.st_mtime < 120));
  266. }' > conftest.c
  267. eval $compile
  268. ./conftest || DEFS="$DEFS -DUTIME_NULL_MISSING"
  269. rm -f conftest conftest.c uttest
  270.  
  271. case "$LIBOBJS" in
  272. *rename.o*)
  273.   LIBPROGS="$LIBPROGS mvdir"
  274.   DEFS="$DEFS -DMVDIR="'\\"$(libdir)/mvdir\\"'
  275.   ;;
  276. esac
  277.  
  278. echo checking for Minix
  279. if test -d /usr/include/minix; then
  280.   DEFS="$DEFS -UUSG -D_POSIX_SOURCE -D_POSIX_1_SOURCE=2 -D_MINIX"
  281. fi
  282.  
  283. echo checking for Xenix
  284. if test -f /xenix; then
  285.   LIBS="$LIBS -lx"
  286.   case "$DEFS" in
  287.   *SYSNDIR*) ;;
  288.   *) LIBS="-ldir $LIBS" ;; # Make sure -ldir precedes any -lx.
  289.   esac
  290. fi
  291.  
  292. echo checking how to get alloca
  293. echo '
  294. #ifdef __GNUC__
  295. #define alloca __builtin_alloca
  296. #else
  297. #ifdef sparc
  298. #include <alloca.h>
  299. #else
  300. #ifdef _AIX
  301.  #pragma alloca
  302. #else
  303. char *alloca ();
  304. #endif
  305. #endif
  306. #endif
  307. main() { char *p = (char *) alloca(1); exit(0); }' > conftest.c
  308. eval $compile
  309. if test -s conftest && ./conftest 2>/dev/null; then :
  310. elif test -d /usr/ucblib; then LIBS="$LIBS -L/usr/ucblib -lucb"
  311. else LIBS="$LIBS -lPW"
  312. fi
  313. rm -f conftest conftest.c
  314.  
  315. trap 'rm -f Makefile lib/Makefile src/Makefile man/Makefile config.status; exit 1' 1 3 15
  316.  
  317. for dir in . lib src man
  318. do
  319.   test -d $dir || mkdir $dir
  320.   echo '# Generated automatically from Makefile.in by configure.' > $dir/Makefile
  321.   sed -e "
  322. $vpsub
  323. s,@srcdir@,$srcdir,
  324. s,@VPATH@,$VPATH,
  325. s,@CC@,$CC,
  326. s,@RANLIB@,$RANLIB,
  327. s,@PROGS@,$PROGS,
  328. s,@DEFS@,$DEFS,
  329. s,@LIBS@,$LIBS,
  330. s,@LIBPROGS@,$LIBPROGS,
  331. s,@LIBOBJS@,$LIBOBJS,
  332. " $srcdir/$dir/Makefile.in >> $dir/Makefile
  333. done
  334.  
  335. echo "CC = $CC
  336. RANLIB = $RANLIB
  337. PROGS = $PROGS
  338. DEFS = $DEFS
  339. LIBS = $LIBS
  340. LIBPROGS = $LIBPROGS
  341. LIBOBJS = $LIBOBJS" > config.status
  342.